import { BasicColumn } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
import { useI18n } from '/@/hooks/web/useI18n';
import { FormSchema } from '/@/components/Table';
const { t } = useI18n('asset.inventoryManagement.fields');
const { t: common } = useI18n('common');
const { t: asset } = useI18n('asset.assetInfo.fields');
const inventoryField = {
  inventoryNumber: t('inventory_number'),
  inventoryName: t('inventory_name'),
  checkState: t('check_state'),
  inventoryState: t('inventory_state'),
  inventoryWay: t('inventort_way'),
  notes: t('notes'),
  inventoryPerson: t('inventory_person'),
  inventoryTime: t('inventoryTime'),
  createTime: t('createTime'),
  createBy: t('createBy'),
  inventory_type: t('inventory_type'),
  count: t('count'),
  actualCount: t('actualCount'),
  actualPosition: t('actualPosition'),
  difference: t('difference'),
};
//列表数据
export const columns: BasicColumn[] = [
  {
    title: inventoryField.inventoryNumber,
    align: 'center',
    dataIndex: 'inventoryNumber',
    fixed: 'left',
  },
  {
    title: inventoryField.inventoryName,
    align: 'center',
    dataIndex: 'inventoryName',
    fixed: 'left',
  },
  {
    title: inventoryField.inventoryState,
    align: 'center',
    dataIndex: 'inventoryState',
    customRender: ({ text }) => {
      return render.renderDict(text, 'inventoryState', true, { '2': 'green', '3': 'blue' });
    },
  },
  {
    title: inventoryField.createBy,
    align: 'center',
    dataIndex: 'createBy_dictText',
  },
  {
    title: inventoryField.createTime,
    align: 'center',
    dataIndex: 'createTime',
  },
  {
    title: inventoryField.inventoryPerson,
    align: 'center',
    dataIndex: 'inventoryPerson_dictText',
  },
  {
    title: inventoryField.inventoryTime,
    align: 'center',
    dataIndex: 'inventory_task.createTime',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: inventoryField.inventoryNumber,
    field: 'inventoryNumber',
    component: 'Input',
  },
  {
    label: inventoryField.createTime,
    field: 'createTime',
    component: 'RangePicker',
  },
  {
    label: inventoryField.inventoryState,
    field: 'inventoryState',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'inventoryState',
      showChooseOption: false,
    },
  },
];
//资产信息数据
export const assetColumns: BasicColumn[] = [
  {
    title: asset('name'),
    dataIndex: 'name',
  },
  {
    title: asset('cartegory'),
    dataIndex: 'cartegory_dictText',
  },

  {
    title: asset('code'),
    dataIndex: 'code',
  },
  {
    title: asset('position'),
    align: 'center',
    dataIndex: 'position_dictText',
  },
  {
    title: asset('useState'),
    dataIndex: 'useState',
    customRender: ({ text }) => {
      return render.renderDict(text, 'useState');
    },
  },
  {
    title: '使用部门',
    dataIndex: 'custodyDepartment_dictText',
  },
  // {
  //   title: inventoryField.count,
  //   align: 'center',
  //   dataIndex: 'count',
  // },
  // {
  //   title: inventoryField.actualCount,
  //   align: 'center',
  //   dataIndex: 'actualCount',
  //   edit: true,
  //   // editRule: true,
  //   editComponent: 'Select',
  //   editComponentProps: {
  //     options: [
  //       { label: '0', value: '0' },
  //       { label: '1', value: '1' },
  //     ],
  //   },
  // },
  // {
  //   title: inventoryField.actualPosition,
  //   align: 'center',
  //   dataIndex: 'actualPosition',
  //   edit: true,
  //   // editRule: true,
  //   editComponent: 'Select',
  //   editComponentProps: {
  //     dict: 'asset_position,position_name,id',
  //     pidField: 'pid',
  //     pidValue: '0',
  //     hasChildField: 'has_child',
  //   },
  // },
];
//查看列表;
export const assetColumnsUnEdit: BasicColumn[] = [
  {
    title: asset('name'),
    dataIndex: 'name',
  },
  {
    title: asset('cartegory'),
    dataIndex: 'cartegory_dictText',
  },

  {
    title: asset('code'),
    dataIndex: 'code',
  },
  {
    title: asset('position'),
    align: 'center',
    dataIndex: 'position_dictText',
  },
  {
    title: asset('useState'),
    dataIndex: 'useState',
    customRender: ({ text }) => {
      return render.renderDict(text, 'useState');
    },
  },
  {
    title: '使用部门',
    dataIndex: 'custodyDepartment_dictText',
  },
  {
    title: inventoryField.actualCount,
    align: 'center',
    dataIndex: 'actualCount',
  },
  {
    title: '位置变动',
    align: 'center',
    dataIndex: 'actualPosition',
  },
];
/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
// export function getBpmFormSchema(_formData): FormSchema[] {
//   // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
//   return formSchema;
// }
